﻿using System;
using System.Collections.Generic;
using Gp.Scripts.Equip;
using UnityEngine;

namespace Gp.Scripts.Core {
    public class ChargeWeaponModel : UnitWeaponModel{
        [SerializeField] private GameObject[] particleOnCharge;
        [SerializeField] private GameObject[] trailsOnCharge;
        private static readonly int Charged = Animator.StringToHash("IsCharged");

        public override IEnumerable<GameObject> Particles {
            get {
                foreach (var particle in base.Particles) {
                    yield return particle;
                }

                if (IsCharged()) {
                    foreach (var particle in particleOnCharge) {
                        yield return particle;
                    }
                } 
            }
        }

        // public override IEnumerable<WeaponTrailEffect> Trails {
        //     get {
        //         foreach (var particle in base.Trails) {
        //             yield return particle;
        //         }
        //
        //         if (IsCharged()) {
        //             foreach (var particle in trailsOnCharge) {
        //                 yield return particle;
        //             }
        //         } 
        //     }
        // }
        private void Update() {
            animator.SetBool(Charged, IsCharged());
        }


        private bool IsCharged() {
            // if (WeaponEntity == null) return false;
            // return this.WeaponEntity.Info is MeleeWeaponInfo {isCharged: true};
            return false;
        }
    }
}